<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>nouveau BC</title>

<!------------------------------ajax---------------------------->
<!-- <script type="text/javascript"  src="http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.js"></script> 
    <script type="text/javascript"  src="http://malsup.github.com/jquery.form.js"></script> -->
	
<!---------------------for autocomplete--------------->
	<script type="text/javascript" src="<?php echo base_url('assets/js/jquery-1.11.0.min.js');?>" ></script>
	<script type="text/javascript" src="<?php echo base_url('assets/js/jquery-ui-1.10.4/js/jquery-ui-1.10.4.min.js');?>" ></script>
	<link href="<?php echo base_url("assets/css/jquery-ui.css")?>" rel="stylesheet" type="text/css" />
<!---------------------for form css ----------------------->
	<link href="<?php echo base_url("assets/css/pure.css")?>" rel="stylesheet" type="text/css" />
<!---------------------for form validation ----------------------->
<script type="text/javascript" src="<?php echo base_url('assets/js/jquery.validate.js');?>" ></script>
<!---------------------for form mask input ----------------------->
<script type="text/javascript" src="<?php echo base_url('assets/js/jquery.mask.min.js');?>" ></script>


</head>
<body>
<?php
include_once('header.php');


// ----- populate $liste_des_fournisseurs array for autocomplete ----- //
$liste_des_fournisseurs = array();
foreach ($fournisseurs as $lf){
	array_push($liste_des_fournisseurs, $lf->nom);
}

$liste_des_charticles = array();
foreach ($charticles as $chart){
	array_push($liste_des_charticles, $chart->nom_art);
	
}
// ----- populate $liste_des_activites array for autocomplete ----- //
$h=1;

?>
<?php
echo form_open_multipart( base_url('bc_ctr/valider_ajout_bc') ); 
$tab=0;
$errors=0;
?>

<form id="bc_form" class="pure-form pure-form-stacked" method="POST" action="<?php echo base_url('bc_ctr/valider_ajout_bc');?>">
    <fieldset>
        <legend style="font-size: 150%"> اضافة وصل طلب </legend>
        <?php
		
		?>
        <div class="pure-g">
            <div class="pure-u-1 pure-u-md-1-3" style="width: 25%">
                <label for="fournisseur">اسم المورد </label>
				<input id="nom" name="fournisseur" type="text" value=" <?php if($nom_fourn) echo($nom_fourn)?>">
				<a href="<?php echo base_url("/bc_ctr/ajout_fournisseur_pour_bc/$tab/$errors")?>" class="pure-button-plus" >+</a>
            </div>

            <div class="pure-u-1 pure-u-md-1-3 " style="width: 20%">
                <label for="article">المادة </label>
                <input  class="ltr" id="article" name="article" type="text" value="">
            </div>
			
			<div class="pure-u-1 pure-u-md-1-3 " style="width: 20%">
                <label for="numero">الرقم </label>
                <input  class="ltr" id="numero" name="numero" type="text" value="">
            </div>
			
			<div class="pure-u-1 pure-u-md-1-3 " style="width: 35%">
                <label for="numero">الرسم على القيمة المضافة </label>
                <input  class="ltr" id="tva" name="tva" type="text" value="17">
            </div>
			
			<!--<div class="pure-u-1 pure-u-md-1-3 " style="width: 30%">
                <label for="numero"> التزام </label>
				<INPUT type="checkbox" name="engagement" value="1">
                
            </div>-->
       </div>
	   </fieldset>

 
	<input type="submit" id="ajouter" value="اضافة"  class="pure-button pure-button-primary" />	
	<a href="<?php echo base_url("/bc_ctr/")?>" class="pure-button pure-button-primary" >خروج</a>
	
</form> 

<div id="msg">
<?php
if($message==1){
	$mmm=0;
	echo('<label for="article">هل تريد اضافة التزام</label>
	<a href="'.base_url("/engagement_crt/ajout_engagement").'/'.$mmm.'" class="pure-button pure-button-primary" >اضافة</a>');
}elseif($message=='erreur'){
	echo('<div id="erreur" style="text-align: center; background-color: red; width: 50%; margin-right: 25%;">
	<label for="article">حقل ادخال الالتزام معبأ بشكل خاطئ</label>
	</div>');
}

?>	
</div>
</body>

<script>
$(document).ready(function() {

var liste_fourniss = <?php echo json_encode($liste_des_fournisseurs); ?>;
var liste_charticle = <?php echo json_encode($liste_des_charticles); ?>;
$( "#nom" ).autocomplete({source: liste_fourniss});
$( "#article").autocomplete({source: liste_charticle});

});

$('#numero').bind('mouseup keyup focusout focus mousemove',function() {
    $('span.error-phone').hide();
	$(this).css('background-color','pink');
    var inputVal = $(this).val();
    var characterReg = /^(\d*)$/;
    if(!characterReg.test(inputVal)) {
        $(this).after('<span class="error-phone" style="color:red;" >حقل غير مطابق للشكل العام </span>');
    }else{
		$(this).css('background-color','#FFFFFF');
	}
});

$('#tva').bind('mouseup keyup focusout focus mousemove',function() {
    $('span.error-phone').hide();
	$(this).css('background-color','pink');
    var inputVal = $(this).val();
    var characterReg = /^(\d+)$/;
    if(!characterReg.test(inputVal)) {
        $(this).after('<span class="error-phone" style="color:red;" >حقل غير مطابق للشكل العام </span>');
    }else{
		$(this).css('background-color','#FFFFFF');
	}
});
</script>

</html>